package com.rentong.wx.cust.controller;

import com.rentong.common.R;
import com.rentong.wx.cust.domain.CustServiceOrderAdvEntity;
import com.rentong.wx.cust.domain.CustServiceOrderEntity;
import com.rentong.wx.cust.dto.CustServiceOrderAdvEntityDto;
import com.rentong.wx.cust.service.CustServiceOrderAdvService;
import com.rentong.wx.utils.WxApiUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author zhangle
 * @email 459343178@qq.com
 * @date 2024-12-24 14:42:32
 */
@RestController
public class CustServiceOrderAdvController {

    @Autowired
    private CustServiceOrderAdvService custServiceOrderAdvService;


    //224、充值，拉起支付（各类充值，具体看orderType）
    @PostMapping("/custServiceOrderAdv/insertAdvOrder")
    public R insertAdvOrder(CustServiceOrderAdvEntity custServiceOrderAdvEntity, HttpServletRequest request) throws Exception {
        custServiceOrderAdvEntity.setCustId(WxApiUtil.getCurrentCustId(request));
        return R.success(custServiceOrderAdvService.insertAdvOrder(custServiceOrderAdvEntity));
    }

    //231、判断是否能拉起打电话
    @RequestMapping("/custServiceOrderAdv/getCanCallPhone")
    public R getCanCallPhone(CustServiceOrderAdvEntityDto custServiceOrderAdvEntityDto, HttpServletRequest request) throws Exception {
        custServiceOrderAdvEntityDto.setCustId(WxApiUtil.getCurrentCustId(request));
        return R.success(custServiceOrderAdvService.getCanCallPhone(custServiceOrderAdvEntityDto));
    }

    //235、取消支付，非服务类型的下单（拉起微信输入密码框之后，点击右上角小叉叉的取消支付）
    @PostMapping("/custServiceOrderAdv/cancelAdvOrder")
    public R cancelAdvOrder(CustServiceOrderAdvEntity custServiceOrderAdvEntity) {
        custServiceOrderAdvService.cancelAdvOrder(custServiceOrderAdvEntity);
        return R.success("操作成功！");
    }


}
